#include "../apue.h"
#include <fcntl.h>

int main(int argc, char ** argv)
{
    int fd;
    int flag;

    fd = strtol(argv[1], NULL, 10);

    if (fd == 0)
        err_sys("fd is not numric");

    if ((flag = fcntl(fd, F_GETFD)) < 0)
        err_sys("fcntl error");

    if (flag & FD_CLOEXEC)
        err_sys("FD_CLOEXEC is open");
    else
        err_sys("FD_CLOEXEC is close");

    exit(0);
}
